package models

import (
	"xy_api/pkg/model"
)

type GoodsInfo struct {
	ID    int64  `json:"id"`
	Stock int64  `json:"stock"`
	Name  string `json:"name"`
	Sales int64  `json:"sales"`
}

func (GoodsInfo) TableName() string {
	return "goods"
}

func GetGoodsInfo(id int64) (GoodsInfo, error) {
	var goods GoodsInfo
	err := model.DB.Where("id=?", id).Find(&goods).Error
	if err != nil {
		return goods, err
	}
	return goods, nil
}
